﻿Imports System.Data.OleDb

Public Class EditRankingPoints
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles grvRankings.SelectedIndexChanged
        Try

            Dim selectedRanking As Users_RankingPointsManagement = New Users_RankingPointsManagement()
            Dim dr As OleDbDataReader = selectedRanking.SelectRankingPointsByRankingPointId(Convert.ToInt32(grvRankings.SelectedValue))
            If dr.HasRows Then
                dr.Read()
                If Not IsDBNull(dr("RankingPointValue")) Then txtValue.Text = dr("RankingPointValue")
            End If

        Catch ex As Exception

        End Try
    End Sub

    Protected Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
        Try

            If (grvRankings.SelectedValue <> Nothing) Then
                Dim updateRanking As Users_RankingPointsManagement = New Users_RankingPointsManagement()
                updateRanking.UpdateRankingPointsByRankingPointId(Convert.ToInt32(grvRankings.SelectedValue), txtValue.Text)

                grvRankings.DataBind()

                lblMessage.Text = "Updated"

            Else

                lblMessage.Text = "You must select a value first"

            End If

        Catch ex As Exception

        End Try
    End Sub
End Class